package cn.itcast.dmp.tags
import org.apache.commons.lang3.StringUtils
import org.apache.spark.sql.Row

object Tags4RegionMaker extends TagsMaker {
  override def make(row: Row, dic: Map[String, String]): Map[String, Double] = {
    // 由于省份和城市标签前缀不一样，所以构建可变集合Map存储标签
    var map: mutable.Map[String, Double] = mutable.Map[String, Double]()
    val provinceValue = row.getAs[String]("province")
    if (StringUtils.isNotBlank(provinceValue)) {
      map += s"PN@$provinceValue" -> 1.0
    }

    // 获取城市的值
    val cityValue = row.getAs[String]("city")
    if (StringUtils.isNotBlank(cityValue)) {
      map += s"CT@$cityValue" -> 1.0
    }

    // 返回Map集合
    map.toMap


  }
}
